﻿$(document).ready(function () {
    var nodes = [];
    var combotree;
    var setting = {
        data: {
            simpleData: {
                enable: true,
                idKey: 'id',
                pIdKey: 'pId',
                rootPId: 0
            }
        },
        callback: {
            onClick: function (event, treeId, treeNode) {
                $('#Input_ParentId_Dropdown').hide();
                location.href = '/Member/Content/Add/' + treeNode.id;
            }
        }
    };
    $.post($("#Input_ParentId_Tree").attr("data-ns-url"), {__RequestVerificationToken: $("input[name='__RequestVerificationToken']").val()
}, function (data) {
        $.each(data, function (index, category) {
            nodes.push({ id: category.categoryId, pId: category.parentId, name: category.name, type: category.moduleType });
        });
        combotree = $.fn.zTree.init($('#Input_ParentId_Tree'), setting, nodes);
        combotree.expandAll(true);
        $('#Input_ParentId_Btn').click(function () { $('#Input_ParentId_Dropdown').show() });
    });
});